/*  Easy DirectShow
 *  Copyright (c) 2008 Zhenfang Tang <helorlove@gmail.com>
 *
 *	This file is part of EasyDS.
 *
 * 	EasyDS is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 * 
 *	EasyDS is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with EasyDS.  If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once
#include <Windows.h>
#include "dshow.h"

enum{EDS_FILE,EDS_DEVICE_PREVIEW,EDS_DEVICE_RECV,EDS_DEVICE_PREVIEW_RECV};
enum{EDS_AVI,EDS_ASF};
enum{EDS_DIVX,EDS_H264};

class CEasyDirectShow
{
public:
	CEasyDirectShow(void);
	~CEasyDirectShow(void);
public:

	bool	Open(LPCWSTR apFileName,int aiLen, char acType);
	bool	SetOwnerWindow(HWND aHwnd);

private:
	void	CloseInterface();

public:
	bool	OpenFile(LPCWSTR apFileName,int aiLen);
	bool	Close();

	bool	Play();
	bool	Stop();
	bool	Pause();

	bool	SeekForward();
	bool	SeekReverse();

	int		GetDuration();
	double  GetCurrentPosition();
	bool	SetCurrentPosition(double aPos);

	bool	SetMute(bool abMute);
	long	GetVolume();
	bool	SetVolume(long alVolume);

	bool	CaptureBitmap(char *apBmpBuff,int aiBuffLen);

	bool	SetVideoPosition(const RECT& rect);
	bool	GetVideoSize(long *width,long *height);

public:
	bool	SetOutputFile(LPCWSTR apFileName,char acSubType,char acEncodeType);

private:
	HRESULT InitCaptureGraphBuilder(IGraphBuilder **ppGraph,
									ICaptureGraphBuilder2 **ppBuild
									);
	

private:
	IGraphBuilder			*mpGB;
	ICaptureGraphBuilder2	*mpGB2;
	IMediaControl			*mpMC;
	IBasicAudio				*mpBA;
	IBasicVideo				*mpBV;
	IMediaSeeking			*mpMS;
	IMediaPosition			*mpMP;
	IVideoWindow			*mpVW;
	IMediaEventEx			*mpEvnt;

	IBaseFilter				*mpMux;
	IBaseFilter				*pEncoder;


	HRESULT hr;
};
